import {handleActions} from "redux-actions"
// 使用lodash
import _ from "lodash";
import{SECKILL_GET_SECKILL,SECKILL_SETLIST_CURPAGE,SECKILL_SETLIST_EACHPAGE,} from "../types"
const InitialValue={
    curPage:1,
    eachPage:5,
    total:0,
    maxPage:0,
    rows:[],
}

export const seckill_list=handleActions({
    // 将传入的数据存储到状态机
    [SECKILL_GET_SECKILL]:(state,{payload})=>{
        const {data}=payload
        console.log("添加的数据",data);
      return  _.assign({},state,data)
    },
    // 设置当前页码
    [SECKILL_SETLIST_CURPAGE]:(state,{payload})=>{
        const {setcurpage}=payload
        return _.assign({},state,{curPage:setcurpage})
    },
    // 设置每页显示的条数
    [SECKILL_SETLIST_EACHPAGE]:(state,{payload})=>{
        const {seteachpage}=payload
        return _.assign({},state,{eachPage:seteachpage})
    },

},InitialValue)